import React from 'react'
import { Text, View } from '@tarojs/components'
import style from './AssistantTitleAndBtnCard.module.scss'

interface Props {
  title: string,
  cardClass?: string,
  contentClass?: string,
  onClickBtn?: () => void,
  btnText?: string,
}

const AssistantTitleAndBtnCard: React.FC<Props> = ({
  children, title = '',
  onClickBtn, cardClass, contentClass,
  btnText
}) => {
  const onClick = (e: { stopPropagation: () => void }) => {
    e.stopPropagation?.()
    onClickBtn?.()
  }
  return (
    <View className={`${style.card} ${cardClass}`}>
      <Text className={style.noteText}>{title}</Text>
      <View className={style.line} />
      <View className={`${style.topicContent} ${contentClass}`}>
        {children}
      </View>
      {!!btnText && (
        <View className={style.viewMoreContainer} onClick={onClick}>
          <Text className={style.viewMoreText}>{btnText}</Text>
        </View>
      )}
    </View>
  )
}

export default AssistantTitleAndBtnCard
